/*     */ package com.qmsk.business.store.salebillpay.controller;
/*     */ 
/*     */ import com.qmsk.business.store.salebillpay.dao.SaleBillPayDAO;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"saleBillPay"})
/*     */ public class SaleBillPayController
/*     */ {
/*  44 */   private static final Logger logger = Logger.getLogger(SaleBillPayController.class);
/*     */ 
/*     */   @Autowired
/*     */   private SaleBillPayDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  55 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  57 */       Map params = new HashMap();
/*  58 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*     */ 
/*  76 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  77 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  79 */       logger.error(e);
/*  80 */       ResponseUtils.setErrorMsgResponse(
/*  81 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/*  89 */       Map params = new HashMap();
/*  90 */       MapUtils.addToMap(params, "id", id);
/*  91 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(params);
/*  92 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  94 */       logger.error(e);
/*  95 */       ResponseUtils.setErrorMsgResponse(
/*  96 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 114 */       int nResult = 0;
/*     */ 
/* 116 */       String sData = RequestUtils.getStringOfData(request);
/* 117 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 118 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 119 */         for (int i = 0; i < p.getListInsertRows().size(); ++i) {
/* 120 */           GsonHeadOneRow r = (GsonHeadOneRow)p.getListInsertRows().get(i);
/* 121 */           r.autoAddHeadData("productDate", new Date());
/* 122 */           r.autoAddHeadData("shopId", shopId);
/*     */         }
/* 124 */         nResult = this.dao.applyUpdates(p, "id");
/*     */       }
/*     */ 
/* 127 */       if (nResult > 0)
/* 128 */         DbConnection.commit();
/*     */       else {
/* 130 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 137 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 138 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 139 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 142 */       logger.error(e);
/* 143 */       DbConnection.rollback();
/* 144 */       ResponseUtils.setErrorMsgResponse(
/* 145 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 146 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}/{id}/{sendRange}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("id") Long id, @PathVariable("sendRange") Integer sendRange)
/*     */   {
/*     */     try
/*     */     {
/* 166 */       int nResult = 0;
/* 167 */       String sData = RequestUtils.getStringOfData(request);
/* 168 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 169 */       if (p != null) {
/* 170 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 172 */       if (nResult > 0)
/* 173 */         DbConnection.commit();
/*     */       else {
/* 175 */         DbConnection.rollback();
/*     */       }
/* 177 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 178 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 179 */         response);
/*     */     } catch (Exception e) {
/* 181 */       logger.error(e);
/* 182 */       DbConnection.rollback();
/* 183 */       ResponseUtils.setErrorMsgResponse(
/* 184 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 185 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 201 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 203 */       String[] strParams = id.split(",");
/* 204 */       int nResult = this.dao.deleteParams(strParams);
/* 205 */       if (nResult > 0)
/* 206 */         DbConnection.commit();
/*     */       else {
/* 208 */         DbConnection.rollback();
/*     */       }
/* 210 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 211 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 212 */         response);
/*     */     } catch (Exception e) {
/* 214 */       DbConnection.rollback();
/* 215 */       logger.error(e);
/* 216 */       ResponseUtils.setErrorMsgResponse(
/* 217 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 218 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"check/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void check(HttpServletRequest request, HttpServletResponse response)
/*     */     throws SQLException
/*     */   {
/* 239 */     int nResult = 0;
/*     */     try
/*     */     {
/* 253 */       if (nResult > 0)
/* 254 */         DbConnection.commit();
/*     */       else {
/* 256 */         DbConnection.rollback();
/*     */       }
/* 258 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 259 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 260 */         response);
/*     */     } catch (Exception e) {
/* 262 */       DbConnection.rollback();
/* 263 */       logger.error(e);
/* 264 */       ResponseUtils.setErrorMsgResponse(
/* 265 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 266 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.salebillpay.controller.SaleBillPayController
 * JD-Core Version:    0.5.3
 */